//
//  UpdateStore.swift
//  StorePlan
//
//  Created by admin on 2020/9/3.
//  Copyright © 2020 admin. All rights reserved.
//

import SwiftUI
import Combine
import RealmSwift

class UpdateStore: ObservableObject {
//
    let didChange = PassthroughSubject<UpdateStore, Never>()
    
    @Published var stores: [StoreData] = []
  
    
    let realm = try! Realm()
    var notificationToken: NotificationToken? = nil
    init() {
        stores = Array(try! Realm().objects(StoreData.self).freeze())
        notificationToken = try! Realm().observe { notification, realm in
            self.stores = Array(try! Realm().objects(StoreData.self).freeze())
        }
    }
    deinit {
        notificationToken?.invalidate()
    }

}
